<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="__STATIC__/js/jquery.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <script type="text/javascript" src="__STATIC__/x-admin/js/xadmin.js"></script>
    <link rel="stylesheet" href="__STATIC__/x-admin/css/font.css">
    <link rel="stylesheet" href="__STATIC__/x-admin/css/xadmin.css">
    <link rel="stylesheet" href="__STATIC__/layui/css/layui.css">


    <link type="text/css" rel="stylesheet" href="__STATIC__/uploads/css/fileinput.css"/>
    <script type="text/javascript" src="__STATIC__/uploads/js/fileinput.js"></script>
    <script type="text/javascript" src="__STATIC__/uploads/js/fileinput_locale_zh.js"></script>
    <link type="text/css" rel="stylesheet" href="__STATIC__/uploads/css/bootstrap.min.css"/>

</head>
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="#">系统设置</a>
        <a href="#">支付使用说明</a>
        <a href="#">添加信息</a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:window.location.reload();" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>

<div style="width: 40%;padding-top: 10px">
    <form class="layui-form" name="addType" onsubmit="return false" id="type">
        <input type="hidden" id="new_video" name="video" >
        <div class="layui-form-item">
            <label class="layui-form-label">标题</label>
            <div class="layui-input-block">
                <input type="text" name="title" placeholder="标题" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">内容</label>
            <div class="layui-input-block">
                <textarea id="demo" style="display: none;"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" id="insert">立即提交</button>
                <button class="layui-btn layui-btn-primary" onclick="window.history.go(-1)">返回</button>
            </div>
        </div>
    </form>
</div>
</body>
</html>
<script>
    layui.use(['upload','layedit'], function() {
        var upload = layui.upload;
        layedit = layui.layedit;
        index = layedit.build('demo',{
            tool: [
                'strong' //加粗
                ,'italic' //斜体
                ,'underline' //下划线
                ,'del' //删除线
                ,'left' //左对齐
                ,'center' //居中对齐
                ,'right' //右对齐
               // ,'image' //插入图片
            ]}
        );
        //建立编辑器
        layedit.getContent(index)
    });
</script>
<script>
    $("#insert").click(function(){
        if(!$("input[name=title]").val()){
            layer.msg('标题不能为空',{icon:5,time:2000});
            return;
        }
        var content = layedit.getContent(index);
        var title = $("input[name=title]").val();
        $.ajax({
            url: "{:url('/pay_set/insert')}",
            data: {
                title:title,
                content:content,
            },
            type: "post",
            dataType: "json",
            success: function(res){
                if(res.code){
                    layer.msg(res.msg,{icon:1,time:2000},function(){
                        window.location.reload();
                    });
                    return;
                }else{
                    layer.msg(res.msg,{icon:5,time:2000});
                    return;
                }
            }
        })
    })
</script>